package com.jqb.jnid.filesys;

import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.Name;
import javax.naming.Reference;
import javax.naming.spi.ObjectFactory;

public class BindedClassFactory implements ObjectFactory{

	@SuppressWarnings("rawtypes")
	@Override
	public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception {
		
		if(obj instanceof Reference){
			Reference ref = (Reference)obj;
			String ip = (String)ref.get("ip").getContent();
			String admin = (String)ref.get("admin").getContent();
			Baidu bd = new Baidu();
			bd.setIp(ip);
			bd.setAdmin(admin);
			return bd;
		}
		
		return null;
	}
	

}
